package com.kaiwukj.android.ufamily.mvp.ui.page.mine.house;

import android.content.res.ColorStateList;
import android.graphics.Color;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.kaiwukj.android.ufamily.R;
import com.kaiwukj.android.ufamily.mvp.http.entity.result.MyHouseMemberResult;
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;

public class MyHouseManagerAdapter extends BaseQuickAdapter<MyHouseMemberResult, BaseViewHolder> {

    private String address;

    public MyHouseManagerAdapter() {
        super(R.layout.item_house_mine_manager, new ArrayList<>());
        addChildClickViewIds(R.id.tv_delete);
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, MyHouseMemberResult itemResult) {
        QMUIRoundButton btnFlag = holder.getView(R.id.btn_flag);

        holder.setText(R.id.tv_name, itemResult.getName());
        holder.setText(R.id.tv_address, String.format("房间号: %s", address));
        holder.setText(R.id.tv_phone, String.format("电话: %S", itemResult.getPhone()));

        if (itemResult.getType() == 1) {
            btnFlag.setBgData(ColorStateList.valueOf(Color.parseColor("#D12A28")));
            btnFlag.setText("业主");
        } else if (itemResult.getType() == 2) {
            btnFlag.setBgData(ColorStateList.valueOf(Color.parseColor("#4F82E6")));
            btnFlag.setText("租户");
        } else {
            btnFlag.setBgData(ColorStateList.valueOf(Color.parseColor("#FDB832")));
            btnFlag.setText("家属");
        }
    }
}
